package com.zhanqiao.Dao;

import com.zhanqiao.Utils.GetDataSourceUtil;
import com.zhanqiao.domain.ArticleBean;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;

public class PublishContentDao implements ArticleDao {
    @Override
    public int insertArticle(ArticleBean articleBean) {
        DataSource ds = GetDataSourceUtil.getDataSource();
        QueryRunner queryRunner = new QueryRunner(ds);
        Object[] parm ={articleBean.getUid(),articleBean.getTitle(),articleBean.getContent(),articleBean.getTag(),articleBean.getPublishDate(),articleBean.getSendstate()};
        String sql ="insert into article(uid,title,content,tag,publishdate,sendstate) value(?,?,?,?,?,?)";
        try {
            int res = queryRunner.update(sql, parm);
            return res;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int deleteArticle(int articleId) {
        return 0;
    }

    @Override
    public List<ArticleBean> selectAll() {
        return null;
    }

    @Override
    public int updateArticle(int id, Date publishdate, String title, String content) {
        return 0;
    }
}
